<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/user/ebao.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.seller_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">收款帐号</div>
                <div class="account_num">
                   我的收款帐号，用于开设店铺交易收款。<font>（仅支持对公帐号）</font>
                   <span>1个</span>
                </div>
                <div class="table">
                    <table>
                        <thead>
                        <tr>
                            <th width="150" class="text-left">电子ID</th>
                            <th width="200" class="text-left">收款帐号</th>
                            <th width="90">类型</th>
                            <th width="90">状态</th>
                            <th width="100">操作</th>
                            <th width="100"></th>
                        </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td class="text-left">
                                    <div class="dzid">42018032945512512485</div>
                                </td>
                                <td class="text-left">
                                    <img class="logo fl" src="{{asset('/img/web/user/czbank_icon.png')}}">
                                    <p style="padding-left: 37px;">
                                        中国工商银行<br>
                                        ****  ****  ****  8541
                                    </p>
                                </td>
                                <td>对公帐号</td>
                                <td>未开通</td>
                                <td>
                                    <div class="cz_box">
                                        <span data-id="1" class="eidt">管理<img src="{{asset('/img/web/user/xia_sj2.png')}}"></span>
                                        <ul>
                                            <li data-id="1" class="setup">设为默认</li>
                                            <li data-id="1" class="del">删除</li>
                                        </ul>
                                    </div>
                                </td>
                                <td>
                                    <div class="default_option">默认收款</div>
                                </td>
                            </tr>
                            <tr>
                                <td class="text-left">
                                    <div class="dzid">42018032945512512485</div>
                                </td>
                                <td class="text-left">
                                    <img class="logo fl" src="{{asset('/img/web/user/czbank_icon.png')}}">
                                    <p style="padding-left: 37px;">
                                        中国工商银行<br>
                                        ****  ****  ****  8541
                                    </p>
                                </td>
                                <td>对公帐号</td>
                                <td>未开通</td>
                                <td>
                                    <div class="cz_box">
                                        <span>管理<img src="{{asset('/img/web/user/xia_sj2.png')}}"></span>
                                        <ul>
                                            <li data-id="2" class="setup">设为默认</li>
                                            <li data-id="2" class="del">删除</li>
                                        </ul>
                                    </div>
                                </td>
                                <td>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="add_account">+添加收款帐号</div>
            </div>
        </div>
    </div>
</div>
<div class="bg_h"></div>
<div class="account_box add_account_box">
    <div class="h_top"><h2>收款帐号管理 </h2><a class="close_box">×</a></div>
    <div class="fl shu_box">
        <span>开户银行</span>
        <input type="text" name="bank_name" class="bank_name">
        <p class="jm_error"></p>
    </div>
    <div class="fl shu_box">
        <span>银行帐号</span>
        <input type="text" name="bank_account" class="bank_account">
        <p class="jm_error"></p>
    </div>
    <div class="fl shu_box">
        <span>银行类型</span>
        <font>对公支付</font>
        <p class="jm_error"></p>
    </div>
    <div class="fl shu_box">
        <span>预留手机号</span>
        <input type="text" name="bank_phone" class="bank_phone">
        <p class="jm_error"></p>
    </div>
    <div class="fl shu_box">
        <span>验证码</span>
        <input type="text" name="bank_code" class="bank_code" autocomplete="off">
        <p class="jm_error"></p>
        <a href="javascript:;" id='send_code' class="js-code">确定</a>
        <div class="fl" id="codetime"></div>
    </div>
    <div class="fl shu_box">
        <span>商城支付密码</span>
        <input type="password" name="bank_pwd" class="bank_pwd" autocomplete="off">
        <p class="jm_error"></p>
    </div>
    <div class="btn_box">
        <div class="btn_cancel close_box">取消</div>
        <div class="btn_confirm add_btn" data-id="1" >确定</div>
    </div>
</div>

@include('web.layout.footer')
<script type="text/javascript">
    $(function(){
      //设为默认
      $('.setup').click(function(){
          var id = $(this).attr('data-id');
          layer.confirm('确定设为默认收款？', {
              btn: ['确定', '取消'] //可以无限个按钮
          }, function (index) {
              $.ajax({
                  url: "",
                  type: 'post',
                  dataType: 'json',
                  data: {'id': id},
                  success: function (data) {
                      if (0 == data.code) {
                          layer.alert("设置成功", {
                              icon: 1
                          }, function () {
                              location.reload();
                          });
                      } else {
                          layer.alert(data.message, {
                              icon: 2
                          });
                      }
                  }
              });
          }, function (index, layero) {
              layer.close(index);
          });
      });
      //删除
      $('.del').click(function(){
          var id = $(this).attr('data-id');
          layer.confirm('确定删除？', {
              btn: ['确定', '取消'] //可以无限个按钮
          }, function (index) {
              $.ajax({
                  url: "",
                  type: 'delete',
                  dataType: 'json',
                  data: {'id': id},
                  success: function (data) {
                      if (0 == data.code) {
                          layer.alert("删除成功", {
                              icon: 1
                          }, function () {
                              location.reload();
                          });
                      } else {
                          layer.alert(data.message, {
                              icon: 2
                          });
                      }
                  }
              });
          }, function (index, layero) {
              layer.close(index);
          });
      });
      var eidt_id;//用于判断添加还修改
      $('.add_account, .eidt').click(function(){
            eidt_id = $(this).attr('data-id');
            $('.bg_h').show();
            $('.add_account_box').show();
            setTimeout(function(){
                $('.bank_code').val('');
                $('.bank_pwd').val('');
            },100);
      });
      $('.close_box').click(function(){
            $('.bank_name').val('');
            $('.bank_account').val('');
            $('.bank_phone').val('');
            $('.bank_code').val('');
            $('.bank_pwd').val('');
            $('.bg_h').hide();
            $('.add_account_box').hide();
      });
      var myDate = new Date();
      var newTime = myDate.getTime();
        var timePoor = $.cookie("endtime") - newTime;

        if(timePoor < 0){
            $.cookie("endtime",null); //使cookie失效
        }
        var maxtime;
        maxtime = parseInt(timePoor/1000);
        var time;
        if(maxtime > 0){
            $(".js-code").hide();
            $("#codetime").show();
            time = setInterval(Count,1000);
        }
        function Count(){
            if(maxtime>=0){
                $(".js-code").hide();
                $("#codetime").show();
                var seconds = Math.floor(maxtime%60);
                var msg = seconds+"秒";
                $("#codetime").html(msg);
                --maxtime;
            }else{
                clearInterval(time);
                $(".js-code").show();
                $("#codetime").hide();
            }
        }
      //企业注册
        $('.js-code').click(function () {
            $('.jm_error').html('');
            var isPhone=/^1[0-9]{10}$/;//手机号码验证
            var phone = $(".bank_phone");
            if (phone.val() == '') {
                phone.parent().find('.jm_error').html('请输入手机号码');
                return false;
            }
            if (!isPhone.test(phone.val())) {
                phone.parent().find('.jm_error').html('手机号码格式不正确');
                return false;
            }
            var mytime = myDate.getTime(); //获取当前时间戳
                        var endtime = mytime+1000*60; //计算结束时间戳
                        $.cookie("endtime",endtime,{expires:endtime});
                        maxtime = 59;
                        time = setInterval(Count,1000);
                        $(".js-code").hide();
                        $("#codetime").html('60秒').show();
                        layer.alert('短信已发放，请注意查收',{icon: 1});
            return false;
            $.ajax({
                url: url,
                type: 'GET',
                dataType: 'json',
                data: {phone:phone.val()},
                success:function (data) {
                    if (data.code == 0) {
                        var mytime = myDate.getTime(); //获取当前时间戳
                        var endtime = mytime+1000*60; //计算结束时间戳
                        $.cookie("endtime",endtime,{expires:endtime});
                        maxtime = 59;
                        time = setInterval(Count,1000);
                        $(".js-code").hide();
                        $("#codetime").html('60秒').show();
                        layer.alert('短信已发放，请注意查收',{icon: 1});
                    }else{
                        layer.alert(data.message,{
                            icon: 2
                        });
                    };
                }
            })
        })
      //添加
      $('.add_btn').click(function(){
            $('.jm_error').html('');
            var isPhone=/^1[0-9]{10}$/;//手机号码验证
            var bank_name = $(".bank_name");
            if (bank_name.val() == '') {
                bank_name.parent().find('.jm_error').html('请输入开户银行');
                return false;
            }
            var bank_account = $(".bank_account");
            if (bank_account.val() == '') {
                bank_account.parent().find('.jm_error').html('请输入银行帐号');
                return false;
            }
            var phone = $(".bank_phone");
            if (phone.val() == '') {
                phone.parent().find('.jm_error').html('请输入手机号码');
                return false;
            }
            if (!isPhone.test(phone.val())) {
                phone.parent().find('.jm_error').html('手机号码格式不正确');
                return false;
            }
            var bank_code = $(".bank_code");
            if (bank_code.val() == '') {
                bank_code.parent().find('.jm_error').html('请输入验证码');
                return false;
            }
            var bank_pwd = $(".bank_pwd");
            if (bank_pwd.val() == '') {
                bank_pwd.parent().find('.jm_error').html('请输入商城支付密码');
                return false;
            }
            $.ajax({
                url: '',
                type: 'POST',
                dataType: 'json',
                data: {},
                success: function (data) {
                    if (data.code == 0) {
                        layer.alert('添加成功',{icon: 1});
                        location.reload();
                    } else {
                        layer.alert(data.message, {
                            icon: 0
                        });
                    }
                }

            })
      });
    });

</script>
</body>
</html>